/* eslint valid-jsdoc: "off" */

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1724030502713_764';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.security = {
    // 关闭 csrf
    csrf: {
      enable: false
    },
    // 跨域白名单
    domainWhiteList: [],
  };
  // 允许跨域的方法
  config.cors = {
    origin: '*',
    allowMethods: 'GET, PUT, POST, DELETE, PATCH'
  };
  config.valparams = {
    locale: 'zh-cn',
    throwError: true
  };
  config.redis = {
    client: {
      port: 6379, // Redis port
      host: "127.0.0.1", // Redis host
      password: "",
      db: 2,
    },
  };
  config.multipart = {
    mode: "file",
    fileExtensions: [".docx", ".pdf"],
  };
  config.middleware = ["errorHandler", "auth"];
  config.auth = {

    match: ["/live/add", "/live/edit", "/live/info", "/gift/wxpay"],
  }
  config.adminAuth = {
    ignore: ["/login", "/userlogin", "/user/add", "/live/mobilelist"]

  }
  config.webUrl = 'http://127.0.0.1:7001'
  config.tenpay = {
    client: {
      appid: 'wxc559eade7d0a3bde',
      mchid: '1554108981',
      partnerKey: '8b07811ec793049f1c97793464c7049f',
      notify_url: config.webUrl + '/gift/notify',
      // sandbox: true
    }
  };
  config.io = {
    init: {
      wsEngine: 'ws',
    },
    namespace: {
      '/': {
        connectionMiddleware: [
  
        ],
        packetMiddleware: [],
      }
    },
    redis: {
      host: '127.0.0.1',
      port: 6379,
      db: 0,
    },
  };
  config.crypto = {
    secret: "qhdgw@45ncashdaksh2!#@3nxjdas*_672",
  };
  config.jwt = {
    secret: "qhdgw@45ncashdaksh2!#@3nxjdas*_672",
  };
  config.session = {
    //延长session有效期
    renew: true,
    //key
    key: "EGG_SESS",
    maxAge: 24 * 3600 * 1000 * 30,
    httpOnly: true,
    encrypt: true
  }
  // 流媒体配置
  config.mediaServer = {
    rtmp: {
      port: 23480,
      chunk_size: 60000,
      gop_cache: true,
      ping: 30,
      ping_timeout: 60,
    },
    http: {
      port: 23481,
      allow_origin: "*",
    },
    auth: {
      play: true,
      publish: true,
      secret: "nodemedia2017privatekey",
    },
  };
  // oss存储
  config.oss = {
    client: {
      accessKeyId: 'LTAI5tFCBhKaDLZpUuyS4pL8',
      accessKeySecret: 'Hzi4BhUwzxfDxvZXWUQbLQDqcWq6gN',
      bucket: 'wangshuo-web1',
      endpoint: 'oss-cn-beijing.aliyuncs.com',
      timeout: '60s',
    },
  };
  config.sequelize = {
    dialect: "mysql",
    host: "127.0.0.1",
    username: "root",
    password: "",
    port: 3306,
    database: "egg-catlive",
    // 中国时区
    timezone: "+08:00",
    define: {
      // 取消数据表名复数
      freezeTableName: true,
      // 自动写入时间戳 created_at updated_at
      timestamps: true,
      // 字段生成软删除时间戳 deleted_at
      // paranoid: true,
      createdAt: "created_time",
      updatedAt: "updated_time",
      // deletedAt: 'deleted_time',
      // 所有驼峰命名格式化
      underscored: true,
    },
  };
  return {
    ...config,
    ...userConfig,
  };
};
